--[[
	@module import
	import [tile layer palette] [file]
]]
local Command = require "command"
local lume = require(LIB_PATH.."lume")

return Command("import", {

	{ "tile", function (filename)
		if not filename then return "No file given" end
		local filename = "tiles/"..filename..".png"
		if _lf.getInfo(filename) then
			local data = _li.newImageData(filename)
			Sled:tile(Sled.grid.tx, Sled.grid.ty):set_img_data (data)
		else
			return "not found"
		end
	end,
	},
	
	{ "layer", function (filename, name)
		if not filename then return "No file given" end
		local name = name or filename
		local filename = "layers/"..filename..".png"
		if _lf.getInfo(filename) then
			Sled.current_map.layers:add(name):import(filename)
		else
			return "File doesn't exist"
		end
	end,
	},
	
	{	"palette", function (filename)
			if filename == "list" or not filename then
				return Sled.gui.palette:list_available ()
			end
			local name = filename .. ".png"
			return  Sled.gui.palette:import_from_file (name)
		end,
	},
	
	{ "map", function (filename)
		if not filename then return "no file given" end
		local file = "maps/"..filename..".map"
		return Sled:import_map (file)
	end,
	}

})
